import { Controller, Get, Post, Delete, Query, Param, Body } from '@nestjs/common';
import { AppService } from './app.service';
import { ApiTags, ApiQuery, ApiProperty } from "@nestjs/swagger";

class User {
  @ApiProperty()
  readonly name:string;
  @ApiProperty()
  readonly id:number;
}

// @ApiTags('tag')
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('/get/:time')
  @ApiQuery({ name: 'role', enum: ['Admin', 'Moderator', 'User']})
  getDemo(@Query('id') id:string, @Param('time') time:string, @Query() query): string {
    return `get id=${id} time=${time} role=${query.role}`
  }

  @Post('/post')
  postDemo(@Body() user:User): string {
    return `post name:${user.name} id:${user.id}`
  }

  @Delete('/delete')
  deleteDemo(): string {
    return 'delete'
  }
}
